package com.qiangqiang.task.server.mapper.provider;

import com.qiangqiang.task.server.entity.MomentsComments;
import org.apache.ibatis.jdbc.SQL;

import java.util.Map;

/**
 * @program: task
 * @description:
 * @author: Sky.lin
 * @create: 2019-01-06 17:16
 **/
public class MomentsCommentsProvider extends BaseProvider {

    public String insertMomentsComments(final Map<String, Object> map) {
        final MomentsComments momentsComments = (MomentsComments) map.get("momentsComments");
        return generateInsertSQL(MomentsComments.class);
    }

    public String queryAllCommentsByMomentsId(final Map<String, Object> map) {
        final long momentsId = (long) map.get("momentsId");

        SQL sql = new SQL() {
            {
                SELECT("*");
                FROM("moments_comments");
                WHERE("moments_id=" + momentsId);
            }
        };
        StringBuffer sb = new StringBuffer(sql.toString());
        return sb.toString();
    }
}
